package com.itstyle.seckill.topic.redis.controller;




import com.itstyle.seckill.topic.redis.Iservice.IRequestAsyncProcessBiz;
import com.itstyle.seckill.topic.redis.Iservice.InventoryProductBiz;
import com.itstyle.seckill.topic.redis.Iservice.Request;
import com.itstyle.seckill.topic.redis.Iservice.serviceImpl.InventoryUpdateDBRequest;
import com.itstyle.seckill.topic.redis.bean.InventoryProduct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.itstyle.seckill.topic.redis.vo.Response;

/**
 * @Auther: liuwenxiang
 * @Date: 2020/2/23 17:55
 * @Description:
 */

@Controller("/inventory1")
public class InventoryUpdateDBController {
    @Autowired
    private  InventoryProductBiz inventoryProductBiz;
    @Autowired
    private IRequestAsyncProcessBiz requestAsyncProcessBiz;


    @RequestMapping("/updateDBInventoryProduct")
    @ResponseBody
    public Response updateDBInventoryProduct(InventoryProduct inventoryProduct){
        //构造一个更新请求，非强制执行-放到队列，交给线程异步执行
        Request request = new InventoryUpdateDBRequest(inventoryProduct,inventoryProductBiz);
        requestAsyncProcessBiz.process(request);
        return new Response(Response.SUCCESS,"更新成功");
    }
}

